package com.huluobo.a2205monthdemo.x5

import android.content.Context
import android.util.AttributeSet
import com.tencent.smtt.sdk.WebView
import com.tencent.smtt.sdk.WebViewClient

/**
 *  Created by LC on 2024/10/7.
 */
class X5WebView(context: Context, attributeSet: AttributeSet) : WebView(context, attributeSet) {
    private val webViewClient = object : WebViewClient() {
        override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
            if (view != null && url != null) {
                view.loadUrl(url)
            }
            return true
        }
    }

    init {
        setWebViewClient(webViewClient)
        initWebViewSetting()
        view.isClickable = true
    }

    private fun initWebViewSetting() {
        val webViewSetting = settings
        webViewSetting.javaScriptEnabled = true
    }

}